Imports System.IO
Imports GenCode.CommonSpace

Namespace CommonSpace
    Public Interface IWrite2File
        Sub Write2File()
    End Interface
End Namespace
Namespace WriterSpace
    Public Class CClassWriter
        Implements IWrite2File
        Public Components As IWrite2File()

        Private Sub imp_IWrite2File_Write2File() Implements IWrite2File.Write2File
            Dim v_com As IWrite2File
            For Each v_com In Components
                v_com.Write2File()
            Next
        End Sub

        'Public Const OL_Level1 As String = Constants.vbTab
        'Public Const OL_Level2 As String = Constants.vbTab & Constants.vbTab
        'Public Const OL_Level3 As String = Constants.vbTab & Constants.vbTab & Constants.vbTab
        'Public Const OL_Level4 As String = Constants.vbTab & Constants.vbTab & Constants.vbTab & Constants.vbTab
        'Public Const c_CRLF As String = Constants.vbCrLf

        'Public Sub Write2File(ByVal i_ds As DataSet, ByVal i_fFileStream As StreamWriter, ByVal i_Author As String)
        '    WriteHeader(i_Author, i_ds, i_fFileStream)
        'End Sub

        'Public Sub WriteHeader(ByVal i_Author As String, _
        '                      ByVal i_ds As DataSet, ByVal i_fFileStream As StreamWriter)
        '    i_fFileStream.WriteLine("'************************************************")
        '    i_fFileStream.WriteLine("'* Generated by: " & i_Author)
        '    i_fFileStream.WriteLine("'* Date: " & Format(Now(), "dd/MM/yyyy"))
        '    i_fFileStream.WriteLine("'* Goal: Create User Service Class for " & i_ds.Tables(0).TableName)
        '    i_fFileStream.WriteLine("'************************************************")
        '    i_fFileStream.WriteLine()
        '    i_fFileStream.WriteLine("option Explicit On")
        '    i_fFileStream.WriteLine("option Strict On")
        '    i_fFileStream.WriteLine()
        '    i_fFileStream.WriteLine("Imports eSchool.eSchoolData")
        '    i_fFileStream.WriteLine("Imports eSchool.eSchoolBusiness")
        '    i_fFileStream.WriteLine("Imports eSchool.eSchoolCommon")
        '    i_fFileStream.WriteLine()
        '    i_fFileStream.WriteLine("Public Class US_" & i_ds.Tables(0).TableName)
        '    i_fFileStream.WriteLine(Constants.vbTab & "Inherits US_Object")
        '    i_fFileStream.WriteLine()
        '    i_fFileStream.WriteLine(OL_Level1 & "Private Const c_TableName as String = """ & i_ds.Tables(0).TableName & """")
        '    i_fFileStream.WriteLine()
        '    i_fFileStream.WriteLine("#Region ""Public Property""")
        '    i_fFileStream.WriteLine()
        '    WriteProperties(i_ds, i_fFileStream)
        '    i_fFileStream.WriteLine("#End Region")
        '    i_fFileStream.WriteLine()
        '    WriteNew(i_ds, i_fFileStream)
        '    i_fFileStream.WriteLine("End Class")
        'End Sub

        'Public Sub WriteProperties(ByVal i_ds As DataSet, ByVal i_fFileStream As StreamWriter)
        '    Dim v_Col As DataColumn
        '    Dim v_Property As New CProperty()
        '    Dim v_str As String
        '    For Each v_Col In i_ds.Tables(0).Columns
        '        v_Property.SetValues(v_Col.DataType, v_Col.ColumnName)
        '        v_str = ""
        '        v_str &= OL_Level1 & "Public Property " & v_Property.getName4Property() & "() As " & v_Property.getDataType() & c_CRLF
        '        v_str &= OL_Level2 & "Get" & c_CRLF
        '        v_str &= OL_Level3 & v_Property.getReturnCodeLine() & c_CRLF
        '        v_str &= OL_Level2 & "End Get" & c_CRLF

        '        v_str &= OL_Level2 & "Set(ByVal Value As " & v_Property.getDataType() & ")" & c_CRLF
        '        v_str &= OL_Level3 & "pm_objDR.Item(""" & v_Property.getName() & """) = Value" & c_CRLF
        '        v_str &= OL_Level2 & "End Set" & c_CRLF
        '        v_str &= OL_Level1 & "End Property" & c_CRLF
        '        i_fFileStream.WriteLine(v_str)
        '    Next
        'End Sub

        'Public Sub WriteNew(ByVal i_ds As DataSet, ByVal i_fFileStream As StreamWriter)
        '    i_fFileStream.WriteLine()
        '    Dim v_str As String
        '    v_str = ""
        '    v_str &= OL_Level1 & "Public Sub New()" & c_CRLF
        '    v_str &= OL_Level2 & "pm_objDS = New DS_" & i_ds.Tables(0).TableName & "()" & c_CRLF
        '    v_str &= OL_Level2 & "pm_strTableName = c_TableName" & c_CRLF
        '    v_str &= OL_Level2 & "pm_objDR = pm_objDS.Tables(pm_strTableName).NewRow()" & c_CRLF
        '    v_str &= OL_Level1 & "End Sub" & c_CRLF

        '    i_fFileStream.WriteLine(v_str)

        '    'Viet ham new theo DataRow
        '    v_str = ""
        '    v_str &= OL_Level1 & "Public Sub New(ByVal i_objDR As DataRow)" & c_CRLF
        '    v_str &= OL_Level2 & "Me.New()" & c_CRLF
        '    v_str &= OL_Level2 & "Me.DataRow2Me(i_objDR)" & c_CRLF
        '    v_str &= OL_Level1 & "End Sub" & c_CRLF
        '    i_fFileStream.WriteLine(v_str)

        '    'Viet ham New theo ID
        '    v_str = ""
        '    v_str &= OL_Level1 & "Public Sub New(ByVal i_dbID As Decimal)" & c_CRLF
        '    v_str &= OL_Level2 & "pm_objDS = New DS_" & i_ds.Tables(0).TableName & "()" & c_CRLF
        '    v_str &= OL_Level2 & "pm_strTableName = c_TableName" & c_CRLF
        '    v_str &= OL_Level2 & "Me.FillDataset(pm_objDS, "" WHERE ID = "" & Str(i_dbID))" & c_CRLF
        '    v_str &= OL_Level2 & "pm_objDR = getRowClone(pm_objds.Tables(pm_strTableName).Rows(0))" & c_CRLF
        '    v_str &= OL_Level1 & "End Sub" & c_CRLF

        '    i_fFileStream.WriteLine(v_str)
        'End Sub

    End Class
End Namespace